
__author__ = 'redsxz(bronze1man@gmail.com)'
__version__ = '0.3.8'

import Wcrypto
import traceback
import datetime
aa=Wcrypto.Wcrypto()
bb=Wcrypto.Wcrypto()
data=''
data_right='123123113213213213211231'
data1M='abcedefhjk'*1000*100+'lala'
key='sdfasfaefsd12321'

def test(smode):
    global aa,bb
    global data
    try:
        start=datetime.datetime.now()
        aa.__init__(smode)
        cc=aa.encrypt(data,key)
        bb.__init__(smode)
        dd=bb.decrypt(cc,key)
        end=datetime.datetime.now()
    except ImportError:
        print 'Do not have the module'
        return
    except AttributeError:
        print 'Do Not have the mode'
        return
    except:
        print
        print str(traceback.format_exc())
        return
    print 'realmode=',aa.realmodestr(),'time',str(end-start),
    if (dd==data):print 'Right'
    else:print 'Wrong'

def Round1M(smode):
    global data
    print '1Mtest',
    data=data1M
    print smode,
    test(smode)

def RoundBase(smode):
    global data
    print 'Base test',
    data=data_right
    print smode,
    test(smode)

_ListofCiphers = ['AES','ARC2','ARC4','Blowfish','CAST',
                    'DES','DES3','IDEA','RC5','XOR']

_ListofModes   = ['ECB','CBC','CFB','OFB','PGP']

#for a in xrange(1,10000):
#  ss=Wcrypto.RandomMethod()
#  Round(ss)
print 'text/plain'
print
Round1M('XOR--0')
Round1M('XOR--32')
Round1M('AES-ECB')
Round1M('AES-CBC')
Round1M('AES-CFB')
Round1M('AES-OFB')

for x in _ListofCiphers:
 RoundBase(x)
 for y in _ListofModes:
  RoundBase(x+'-'+y)
for x in _ListofCiphers:
 for y in _ListofModes:
  for z in xrange(1,33):
   RoundBase(x+'-'+y+'-'+str(z))
